package com.ljj.controller;

import com.ljj.pojo.College;
import com.ljj.pojo.Exam;
import com.ljj.service.CollegeService;
import com.ljj.service.ExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author LJJ
 * @create 2020-07-12
 */
@Controller
public class ToController {

    @Autowired
    ExamService examService;

    @Autowired
    CollegeService collegeService;

    //    去考试报名页面
    @RequestMapping("toExamRe")
    public String toExamRe(Model model){
        List<College> colleges = collegeService.QueryCollege();
        model.addAttribute("colleges",colleges);
        return "college/colleges";
    }

    //    去查看学生页面
    @RequestMapping("toStuByC")
    public String toStuByCollege(Model model){
        List<College> colleges = collegeService.QueryCollege();
        model.addAttribute("colleges",colleges);
        return "student/student";
    }


//    前往添加页面
    @RequestMapping("toIE")
    public String toIE(Model model){
        model.addAttribute("type","insert");
        return "exam/UIExam";
    }

    //    前往修改页面
    @RequestMapping("toUE")
    public String toUE(int id,Model model){
        Exam exam = examService.queryOneExam(id);
        model.addAttribute("type","update");
        model.addAttribute("exam",exam);
        return "exam/UIExam";
    }


    //    前往首页
    @RequestMapping("/")
    public String toIndex(){
        return "redirect:index.html";
    }
}
